﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1对1
{
    public class OrderConfig : IEntityTypeConfiguration<Order>
    {
        public void Configure(EntityTypeBuilder<Order> builder)
        {
            builder.ToTable("T_Orders");
            //配置外键
            //HasForeignKey：类型参数：拥有外键的实体类型；参数：指定外键
            builder.HasOne<Delivery>(x => x.Delivery).WithOne(x => x.Order)
                .HasForeignKey<Delivery>(x => x.OrderId);
        }
    }
}
